<%--
  作者:张伟

  联系:adamzzww@163.com
  时间:2016-11-30
  说明:菜单列表
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="renderer" content="webkit">
    <title><%=Global.TITLE%>
    </title>
    <%@include file="../../desktop/include/assets.jsp" %>
    <%
        String url = request.getContextPath() + Global.PATH + "/menu";
    %>
    <style>

    </style>
</head>
<body>
<div class="page-wrapper">

    <%@include file="../../desktop/include/navigator.jsp" %>

    <div>
        <ul class="breadcrumb">
            <li><a href="<%=request.getContextPath()%><%=Global.INDEX_PAGE%>">首页</a></li>
            <li><a href="#" class="active">菜单管理</a></li>
        </ul>
    </div>

    <!--标题-->
    <h3>菜单管理</h3>

    <!--内容开始-->
    <div class="row clearfix">
        <div class="col-md-12 column customcontainer">
            <div class="cu">
                <table class="table table-bordered">
                    <tr>
                        <th>菜单名称</th>
                        <th>菜单资源路径</th>
                        <th>上级菜单</th>
                        <th>菜单排序</th>
                        <th>操作</th>
                    </tr>
                    <c:if test="${!empty page.getContent() }">
                        <c:forEach items="${page.getContent() }" var="menu">
                            <tr>
                                <td>${menu.menuName }</td>
                                <td>${menu.menuUrl }</td>
                                <td>
                                    <c:forEach items="${menuList }" var="curMenu">
                                        <c:if test="${menu.pMenuId == curMenu.menuId}">
                                            ${menu.menuName}
                                        </c:if>
                                    </c:forEach>
                                </td>
                                <td>${menu.menuOrder }</td>
                                <td>
                                    <button type="button" class="btn btn-xs btn-success"
                                            data-iframe="<%=url%>/${menu.menuId }"
                                            data-toggle="modal" data-title="编辑菜单信息">编辑
                                    </button>
                                    <button type="button" data-position="center" class="btn btn-xs btn-danger"
                                            data-toggle="modal"
                                            data-target="#delAlarm" onClick="delClick(${menu.menuId })">删除
                                    </button>
                                </td>
                            </tr>
                        </c:forEach>
                    </c:if>
                </table>

                <!--按钮+分页开始-->
                <div class="btn_nav">
                    <div class="left">

                        <button type="button" class="btn btn-primary" data-iframe="<%=url%>/add"
                                data-toggle="modal" data-title="新增菜单信息">增加
                        </button>

                    </div>
                    <div class="right">
                        <ul id="pagination" class="pager pagination-sm pagination">
                        </ul>
                    </div>
                </div>
                <!--按钮+分页结束-->
            </div>
        </div>
    </div>
    <!-- 删除对话框HTML -->
    <div class="modal fade" id="delAlarm">
        <div class="modal-dialog modal-sm">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span
                            class="sr-only">关闭</span></button>
                    <h4 class="modal-title ">警告</h4>
                </div>
                <div class="modal-body">
                    <p>是否确定删除！</p>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    <button id="delBtn" data-id="" type="button" class="btn btn-danger">删除</button>
                </div>

            </div>
        </div>
    </div>

    <script>

        $("#pagination").twbsPagination({
                    first: '首页',
                    prev: '上一页',
                    next: '下一页',
                    last: '尾页',
                    totalPages:  ${page.getTotalPages() },
                    visiblePages: ${page.getTotalPages() } < 5 ? ${page.getTotalPages()} : 5,
                href
        :
        '?pageIndex={{number}}'
        })
        ;

        function delClick(data) {
            $("#delBtn").attr('data-id', data);
        }

        $(function () {

            $("#delBtn").click(function () {
                var id = $(this).attr('data-id');
                $.ajax(
                        {
                            url: '<%=url%>/' + id,
                            type: "post",
                            async: true,
                            data: {_method: "delete"},
                            error: function () {
                                alert("删除出错！");
                            },
                            success: function (data) {
                                //alert("数据删除成功！");
                                //$("#delAlarm").modal("hide", "fit");
                                window.location.reload();
                            }
                        }
                );
            });
        });

    </script>

    <%@include file="../../desktop/include/bottom.jsp" %>

</div>
</body>
</html>
